package org.itboys.core.controller.front;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.core.dto.coupon.SundayCouponDto;
import org.itboys.core.service.mongo.front.SundayFrontCouponService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author：贾琦磊
 * @Date：2018/8/29
 * @Description：优惠券
 */
@Controller
@RequestMapping("/sunday/small/coupon")
@Api(value = "Coupon",description = "优惠券部分接口")
public class SundayFrontCouponController extends BaseController{

    @Autowired
    private SundayFrontCouponService couponService;

    @ApiOperation(value = "用户获取优惠券，分页，状态必传")
    @RequestMapping(value = "/select",method = RequestMethod.POST)
    public void select(HttpServletRequest request, HttpServletResponse response
                ,@ApiParam(value = "用户id",name = "memberId")@RequestParam(value = "memberId")Long memberId
             , @ApiParam(required = true,value = "状态：5--已领取，3--已使用，4--已过期，6--可领取",name = "state")@RequestParam(value = "state")Integer state
            ,@ApiParam(required = true, name = "pageSize", value = "分页参数。每页数量。") @RequestParam(value = "pageSize") String pageSize
            ,@ApiParam(required = true, name = "pageNumber", value = "分页参数。第几页。") @RequestParam(value = "pageNumber") String pageNumber)throws Exception{
        List<SundayCouponDto> result = couponService.select(request, memberId, state);
        ResponseMessage.success(result);
    }
}
